package com.lvcoding.auth2.auth.shizhan.verifycode.img;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import com.lvcoding.auth2.auth.shizhan.verifycode.parent.VerifyCodeGenerator;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.ServletWebRequest;

@Component
public class ImgVerifyCodeGenerator implements VerifyCodeGenerator {
    @Override
    public ImgCode generate(ServletWebRequest servletWebRequest) throws Exception {
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100, 4, 6);
        String code = lineCaptcha.getCode();
        return new ImgCode(code, lineCaptcha.getImage(), 1);
    }
}
